<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${rootPath}/css/a.css" type="text/css" rel="stylesheet" />
<link href="${rootPath}/css/index.css" type="text/css" rel="stylesheet" />
<link href="${rootPath}/css/common.css" type="text/css" rel="stylesheet" />
<title>云商宝终端SN查询</title>

<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/common.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/engine.js"/>'></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/MccQuery.js"/>'></script>
<script type="text/javascript">
$(document).ready(function(){

      $("#sub").click(function(){
          if(!checkDate()){
              return false;
            }
         $("#importForm").attr("action","<%=basePath%>/ysbTermSnStatisDetail/queryTermSnStatisDetail.ct");
		 $("#importForm").submit();
       
      });
      
      $("#szPower").click(function() {
          if(!checkDate()){
              return false;
            }
		 $("#importForm").attr("action","<%=basePath%>/ysbTermSnStatisDetail/excelTermSnStatisDetail.ct");
		 $("#importForm").submit();
	   });	
   });

function   str2date(str){
	var d=null;   
	var reg=/^(\d{4})(\d{2})(\d{2})$/  ;
		if(arr=str.match(reg))d=new   Date(Number(arr[1]),Number(arr[2])-1,Number(arr[3])) ; 
	return   d;   
}  

function  checkDate(){
	var endTime = $("#maxDate").val();
	var beginTime = $("#minDate").val();
 
	if(!endTime || !beginTime){
		alert("起始时间范围必须选择!");
		return false;
	} 
	var date1=str2date(beginTime);
	var date2=str2date(endTime);
	/* 	
	if(date1.getMonth()!=date2.getMonth()){
	    alert("选择的起始时间不在同一个月内！");
		return false;
	} */ 
    var dateSpan = date2 - date1;
    dateSpan = Math.abs(dateSpan);
    iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
	if( (iDays+1) > 90){
		alert("选择的起始~结束时间跨度不能大于90天！");
		return false;
	} 
	var d1 = new Date(date1);
	var d2 = new Date(date2);
	if(d1 > d2){
		alert("选择的结束时间不能小于起始时间！");
		return false;
	}
	return true;
}
	
</script>
</head>
<body>
<table class="tb">
    <tbody>
		<s:form id="importForm" action="queryTermSnStatisDetail.ct" method="post"
			namespace="/ysbTermSnStatisDetail"  theme="simple">
			
		        <tr class="tb-line">
		            <td class="tb-td" colspan="6"><div class="tb-h2">POS收单运营管理平台</div></td>
		        </tr>
		
		        <tr class="tb-line">
		            <td class="tb-td" colspan="6"><div class="tb-h3">云商宝终端统计明细</div></td>
		        </tr>

				<tr class="tb-line">
					<td width="12%" style="min-width: 150px" align="right" class="tb-td">
		                <div class="tb-h4">资产类型：</div>
		             </td>
					<td class="tb-td">
                		<label class="tb-select">
							<s:select cssClass="queryWidth" name="searchCondition.assefFlag"
								id="assefFlag"
								list="#request.assefMap" listKey="key" listValue="value"  headerKey="-1" headerValue="--请选择--"/>
						</label>
					</td>
					<td width="12%" style="min-width: 150px" align="right" class="tb-td">
			                <div class="tb-h4">手机号：</div>
			   		</td>
					<td class="tb-td" >
		                <label class="tb-input-normal">
							<s:textfield id="phoneno" name="searchCondition.phoneno" cssClass="queryWidth" />
						</label>
                	</td>
				</tr>
				
				<tr class="tb-line">
	            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
	                <div class="tb-h4">绑定日期：</div></td>
	            <td class="tb-td">
	                <label class="tb-input-mini">
	                	<s:textfield id="minDate" name="searchCondition.minDate" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth" /> 
					</label>至：
					<label class="tb-input-mini">
						<s:textfield id="maxDate" name="searchCondition.maxDate" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth" />
					</label>
					<code class="asterisk">*</code>
				</td>	
				</tr>
				<tr>
					<td colspan="6">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="6" align="center"><div style="color: blue;">
							<s:actionmessage />
						</div>
						<div style="color: red;">
							<s:actionerror />
						</div>
					</td>
				</tr>

				<tr class="tb-line">
					<td class="tb-td line-submit" align="right" colspan="6">
                		<label class="tb-input-submit">
					 		<s:submit value="查询" id="sub" /> 
		                </label>
		                <label class="tb-input-submit">
				             <s:reset value="取  消" />
		                </label>
						   <s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
								
				                <label class="tb-input-submit">
									<input id="szPower" type="submit" value="导出Excel" />
				                </label>
					       </s:if>
						   <s:else>
						   
			                <label class="tb-input-submit">
								<input id="szPower" disabled="disabled" value="导出Excel" type="submit" />
			                </label>
					       </s:else>
							</td>
				</tr>
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<s:if  test="#request.searchRsList != null && #request.searchRsList.size>0">
					<tr class="tb-line">
						<td class="tb-td paging" colspan="12" align="left">&nbsp;&nbsp;&nbsp;&nbsp; <page:pageCount
								max_pages="11" totalPage="${requestScope.totalPage}"
								currentPage="${requestScope.currentPage}"
								action="${rootPath}/ysbTermSnStatisDetail/queryTermSnStatisDetail.ct?currentPage=" />

						</td>
					</tr>
					</s:if>
			</table> 
		</s:form>
    </tbody>
</table>
<div class="big-tb">
    <table class="tb" style="width: 100%;">
				<thead>
		            <tr class="tb-line">
		                <th class="tb-th" colspan="8">终端统计明细列表</th>
		            </tr>
					<tr class="tb-line bg-gray">
					
						<th class="tb-th">商户号</th>
						<th class="tb-th">商户名称</th>
						<th class="tb-th">手机</th>
						<th class="tb-th">资产类型</th>
					    <th class="tb-th">终端序列号</th>
						<th class="tb-th">品牌</th>
						<th class="tb-th">型号</th>
						<th class="tb-th">机型</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="#request.searchRsList" status="stat" id="term">
						<tr class="tb-line">
							<td class="tb-td" align="center">
							 <s:property value="#term.mercCode"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.mercName"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.phoneno"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.assefFlag"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.serialNum"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.posBrand"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.posName"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.posType"/>
							</td>
						</tr>
						</s:iterator>
				</tbody>
    </table>
</div>
</body>
</html>